import { Body, Controller, Delete, Get, Post, Query, UploadedFiles, UseInterceptors } from '@nestjs/common';
import { FileManageService } from './file_manage.service';
import { FileFieldsInterceptor } from '@nestjs/platform-express';

@Controller('fileManage')
export class FileManageController {
    constructor(
        private readonly fileManageService: FileManageService
    ) { }

    @Post('upload')
    @UseInterceptors(FileFieldsInterceptor([
        { name: 'videos', maxCount: 99 },
    ], { limits: { fileSize: 9999999999 } }))
    upload(@UploadedFiles() files: any) {
        return this.fileManageService.upload(files);
    }

    @Get()
    index(@Query() query) {
        return this.fileManageService.findAll(query);
    }

    @Get('getVideosByName')
    getVideosByName(@Query() query: any) {
        return this.fileManageService.getVideosByName(query);
    }

    @Delete('delete')
    delete(@Body() body: any) {
        return this.fileManageService.delete(body);
    }
}
